﻿$(function(){
    var len =0; 
	

	index_scroll_03('#s10 ul','#s10 .aright','#s10 .aleft',256,3,'.scroll-li','.susp_cont');
	
	//if($.cookie("cs_cid") == null){
	//}else{
	$.ajax({
		type: "post",
		cache:false,
		url: "http://www.ccb.com/tran/WCCMainPlatV5?CCB_IBSVersion=V5&SERVLET_NAME=WCCMainPlatV5&TXCODE=NHY000&jsoncallback=?",
		dataType: "jsonp",
		success: function (data) {
		var output = data;
		var loginStatus=output.loginStatus;
		if(loginStatus=="1"){
			
		}else{
			number();
			if(loginStatus=="0"){
				getKHXJRight();
			}
			yingyong();
			var name=output.showName;
			var date=output.sysTime;
			var year=date.substring(0,4);
			var month=date.substring(4,6);
			var day=date.substring(6,8);
			var week=new Date(year,month-1,day).getDay();
			if(week==0){
				week=year+"年"+month+"月"+day+"日"+"星期日";
			}else if(week==1){
				week=year+"年"+month+"月"+day+"日"+"星期一";
			}else if(week==2){
				week=year+"年"+month+"月"+day+"日"+"星期二";
			}else if(week==3){
				week=year+"年"+month+"月"+day+"日"+"星期三";
			}else if(week==4){
				week=year+"年"+month+"月"+day+"日"+"星期四";
			}else if(week==5){
				week=year+"年"+month+"月"+day+"日"+"星期五";
			}else{
				week=year+"年"+month+"月"+day+"日"+"星期六";
			}
			var time=output.lastLoginTime;
			if(time!=null&&time!=""){
				
			
				if(time.indexOf(':')!=-1){
					var year1=time.split(" ")[0].split("-")[0];
				    var month1=time.split(" ")[0].split("-")[1];
					var day1=time.split(" ")[0].split("-")[2];
					var hours=time.split(" ")[1].split(":")[0];
				    var min=time.split(" ")[1].split(":")[1];
					
				}else{ 
				     year1=time.split(".")[0].split("-")[0];
				     month1=time.split(".")[0].split("-")[1];
				     day1=time.split(".")[0].split("-")[2];
				     hours=time.split(".")[1].split("_")[0];
				     min=time.split(".")[1].split("_")[1];
				 }
				 time=year1+"年"+month1+"月"+day1+"日"+hours+":"+min;
			}else{
				time="";
			}
			$(".uesr_info").html("<div class='leftUseimg'><div class='circle_top'><img src='/cn/v3/images/circle_top_white.png'/></div><div class='circle_bottom'><img src='http://login.ccb.com/tran/WCCMainPlatV5?CCB_IBSVersion=V5&SERVLET_NAME=WCCMainPlatV5&TXCODE=D20020'></div></div><div class='info-gr'><dl class='user-item1'><dd>"+name+" 欢迎光临</dd><dd id='myXJLoginAreaShowRightDD' style='display:none;'><span style='float: left;position: static;cursor: auto;'>我的星级：</span><img  id='myXJLoginAreaShowRight' src='http://www.ccb.com/cn/v3/images/khxj/khxj_01.png' style='padding-top: 10px;'></dd><dd></dd><dd><a href='http://www.ccb.com/cn/mycom/user_center.html' target='_blank' class='f_blue'>进入我的.com &gt;</a></dd></dl><dl class='user-item2'><dd class='user-time'>上次登录时间："+time+"</dd><dd class='user-date'><img src='http://www.ccb.com/cn/home/v3/images/tishi.png'>"+week+"</dd></dl></div>");
			$(".susp_cont").html("<div class='susp_cont_tit' id='applyContent'>推荐应用</div><div class='scrolllist' id='s10'><a class='abtn aleft'></a><div class='imglist_w'><ul class='imglist' style='left: 0px;'></ul></div><a class='abtn aright agrayright'></a></div><div class='sus_more fr'><a href='/cn/mycom/user_app_to_management.html' target='_blank'>应用管理 &gt;</a></div>");
		}
		}
	});
//}
	
		function getKHXJRight(){
		$.ajax({
			type: "post",
			cache:false,
			url: "http://www.ccb.com/tran/WCCMainPlatV5?CCB_IBSVersion=V5&SERVLET_NAME=WCCMainPlatV5&TXCODE=NKHXJ0&jsoncallback=?",
			dataType: "json",
			success: function (data) {
				var output = data;
				var custLvl=output.custLvl;
				//alert(custLvl);
				if(custLvl != -1){
					var xjShowSrc = "http://www.ccb.com/cn/v3/images/khxj/khxj_0" + custLvl + ".png"
					document.getElementById("myXJLoginAreaShowRight").src = xjShowSrc;
					document.getElementById("myXJLoginAreaShowRightDD").style.display = "block";
				}
			}
		});
	}	
	
	function number(){
	$.ajax({
		type: "post",
		cache:false,
		url: "http://www.ccb.com/tran/WCCMainPlatV5?CCB_IBSVersion=V5&SERVLET_NAME=WCCMainPlatV5&TXCODE=NMCFR3&jsoncallback=?",
		dataType: "jsonp",
		success: function (data) {
			var output = data;
			var number=output.unreadMsgNumber;
			$(".uesr_info .user-item1 dd:eq(2)").html("<a class='number' href='http://www.ccb.com/cn/mycom/znxx/messageService01.html' onclick='LinkClickFunction(this)' target='_blank'><img src='http://www.ccb.com/cn/home/v3/images/message.jpg'>("+number+")</a>");
		}
	});
	}
	function yingyong(){
	var stmt="";
	$.ajax({
		type: "post",
		cache:false,
		url: "http://www.ccb.com/tran/WCCMainPlatV5?CCB_IBSVersion=V5&SERVLET_NAME=WCCMainPlatV5&TXCODE=NMCMA3&jsoncallback=?",
		dataType: "jsonp",
		success: function (data) {
			if(data.customizedAppNumber==0){
			    $("#applyContent").text('推荐应用');
				for(var i=0;i<data.recommendAppInfos.length;i++){
					 stmt+="<li class='scroll-li'><div class='scroll-li-box'><dl class='li_box_inf'><dt class='li_box_title'>"+data.recommendAppInfos[i].FirstTitle+"</dt> <dd class='li_box_detail'>"+data.recommendAppInfos[i].SecondTitle1+data.recommendAppInfos[i].SecondTitle2+"</dd></dl></div><div class='index_tab_button'><a class='vvc-button1' href='http://www.ccb.com/cn/mycom/user_center.html'>查看详情</a></div><img src='"+data.recommendAppInfos[i].ImageName+"'></div></li>";
				}
				 $("#s10 .imglist").html(stmt);    
			}else{
			    $("#applyContent").text('你已定制的应用');
				for(var i=0;i<data.customizedAppInfos.length;i++){
					 stmt+="<li class='scroll-li'><div class='scroll-li-box'><dl class='li_box_inf'><dt class='li_box_title'>"+data.customizedAppInfos[i].FirstTitle+"</dt> <dd class='li_box_detail'>"+data.customizedAppInfos[i].SecondTitle1+"</p><p>"+data.customizedAppInfos[i].SecondTitle2+"</dd></dl></div><div class='index_tab_button'><a class='vvc-button1' href='http://www.ccb.com/cn/mycom/user_center.html'>查看详情</a></div><img src='"+data.customizedAppInfos[i].ImageName+"'></div></li>";
				}
			   $("#s10 .imglist").html(stmt);
			}
			$("#s10").xslider({
				unitdisplayed:3,
				movelength:3,
				unitlen:248,
				autoscroll:null
			});
		},
		complete:function(){
			len = $('#s10 ul li').length;
           if(len < 4 ){//隐藏
           $('#s10 .aright').hide();
		   $('#s10 .aleft').hide();
          }else{
		    $('#s10 .aleft').removeClass('agrayleft');
		    $('#s10 .aright').addClass('agrayright');
		   }
		   
		  
		}
	});
	}
	 function index_scroll_03(chang_obj,right_obj,left_obj,Swidth,i_num,num_obj,parent_obj){
	     var index = 0 ,i=i_num; //index点击次数，i是一页li个数
	 	 var Awidth = 0;	
	     $(parent_obj).on('click',right_obj,function(){    //下一页

	   	  var Mwidth = len-(index+1)*i;
	      if(Mwidth>i) {
			$(left_obj).addClass('agrayleft');
            $(right_obj).removeClass('index_scroll_right_a_hover');
            $(chang_obj).stop(true, false).animate({left: -(index+1)*Swidth*i+"px"},600);
            index++;
			} else {
            $(left_obj).addClass('agrayleft');
			$(right_obj).removeClass('agrayright');
			Awidth = Mwidth;
            $(chang_obj).stop(true, false).animate({left:-index*Swidth*i-Swidth*Mwidth+"px"},600);
    }
   
       });
	       $(parent_obj).on('click',left_obj,function() { //上一页
		
          if(index==0) {	
	   	  var Mwidth = len-i;

			$(right_obj).addClass('agrayright');
            $(left_obj).removeClass('agrayleft');
            $(chang_obj).stop(true, false).animate({left: "0px"},600);
        }else {
            $(left_obj).addClass('agrayleft');
			//$(right_obj).removeClass('agrayright');
            $(chang_obj).stop(true, false).animate({left: -(index-1)*Swidth-Swidth*Awidth+"px"},600);
           	   index--;
        }

         }); 
		 }
		 
	
});